import { createApp } from 'vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import "./assets/css/global.css"

// 引入 Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

// 引入 axios
import axios from 'axios'
// 通过jwt进行权限验证
axios.interceptors.request.use(config => {
  const token = localStorage.getItem('token');
  if (token) {
    config.headers.Authorization = `Bearer ${token}`;
  }
  return config;
});

// 引入 Pinia
import { createPinia } from "pinia";

const app = createApp(App)

// 使用 Element Plus
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(router)
// 配置 axios 为全局属性
app.config.globalProperties.$axios = axios
// 注册 Pinia
app.use(createPinia());

app.mount('#app')

